.class final Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;
.super Ljava/lang/Object;
.source "UTF8Output.java"


# static fields
.field private static final STATES:[B = null

.field private static final TYPES:[B = null

.field private static final UTF8_ACCEPT:I = 0x0

.field private static final UTF8_REJECT:I = 0xc


# instance fields
.field private codep:I

.field private state:I

.field private final stringBuilder:Ljava/lang/StringBuilder;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 29
    const/16 v0, 0x100

    new-array v0, v0, [B

    fill-array-data v0, :array_0

    sput-object v0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->TYPES:[B

    .line 38
    const/16 v0, 0x6c

    new-array v0, v0, [B

    fill-array-data v0, :array_1

    sput-object v0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->STATES:[B

    return-void

    .line 29
    nop

    :array_0
    .array-data 0x1
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x0t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x1t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x9t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x7t
        0x8t
        0x8t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0x2t
        0xat
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x3t
        0x4t
        0x3t
        0x3t
        0xbt
        0x6t
        0x6t
        0x6t
        0x5t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
        0x8t
    .end array-data

    .line 38
    :array_1
    .array-data 0x1
        0x0t
        0xct
        0x18t
        0x24t
        0x3ct
        0x60t
        0x54t
        0xct
        0xct
        0xct
        0x30t
        0x48t
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0x0t
        0xct
        0xct
        0xct
        0xct
        0xct
        0x0t
        0xct
        0x0t
        0xct
        0xct
        0xct
        0x18t
        0xct
        0xct
        0xct
        0xct
        0xct
        0x18t
        0xct
        0x18t
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0x18t
        0xct
        0xct
        0xct
        0xct
        0xct
        0x18t
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0x18t
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0x24t
        0xct
        0x24t
        0xct
        0xct
        0xct
        0x24t
        0xct
        0xct
        0xct
        0xct
        0xct
        0x24t
        0xct
        0x24t
        0xct
        0xct
        0xct
        0x24t
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
        0xct
    .end array-data
.end method

.method constructor <init>([B)V
    .locals 2
    .parameter "bytes"

    .prologue
    .line 49
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 44
    const/4 v0, 0x0

    iput v0, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    .line 50
    new-instance v0, Ljava/lang/StringBuilder;

    array-length v1, p1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(I)V

    iput-object v0, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->stringBuilder:Ljava/lang/StringBuilder;

    .line 51
    invoke-virtual {p0, p1}, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->write([B)V

    .line 52
    return-void
.end method


# virtual methods
.method public toString()Ljava/lang/String;
    .locals 2

    .prologue
    .line 76
    iget v0, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    if-eqz v0, :cond_0

    .line 77
    new-instance v0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Exception;

    const-string v1, "bytes are not UTF-8"

    invoke-direct {v0, v1}, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Exception;-><init>(Ljava/lang/String;)V

    throw v0

    .line 79
    :cond_0
    iget-object v0, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->stringBuilder:Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public write(I)V
    .locals 3
    .parameter "b"

    .prologue
    .line 61
    sget-object v1, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->TYPES:[B

    and-int/lit16 v2, p1, 0xff

    aget-byte v0, v1, v2

    .line 63
    .local v0, type:B
    iget v1, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    if-eqz v1, :cond_1

    and-int/lit8 v1, p1, 0x3f

    iget v2, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->codep:I

    shl-int/lit8 v2, v2, 0x6

    or-int/2addr v1, v2

    :goto_0
    iput v1, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->codep:I

    .line 65
    sget-object v1, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->STATES:[B

    iget v2, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    add-int/2addr v2, v0

    aget-byte v1, v1, v2

    iput v1, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    .line 67
    iget v1, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    if-nez v1, :cond_2

    .line 68
    iget-object v1, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->stringBuilder:Ljava/lang/StringBuilder;

    iget v2, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->codep:I

    int-to-char v2, v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    .line 72
    :cond_0
    return-void

    .line 63
    :cond_1
    const/16 v1, 0xff

    shr-int/2addr v1, v0

    and-int/2addr v1, p1

    goto :goto_0

    .line 69
    :cond_2
    iget v1, p0, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->state:I

    const/16 v2, 0xc

    if-ne v1, v2, :cond_0

    .line 70
    new-instance v1, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Exception;

    const-string v2, "bytes are not UTF-8"

    invoke-direct {v1, v2}, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Exception;-><init>(Ljava/lang/String;)V

    throw v1
.end method

.method public write([B)V
    .locals 4
    .parameter "bytes"

    .prologue
    .line 55
    move-object v0, p1

    .local v0, arr$:[B
    array-length v3, v0

    .local v3, len$:I
    const/4 v2, 0x0

    .local v2, i$:I
    :goto_0
    if-ge v2, v3, :cond_0

    aget-byte v1, v0, v2

    .line 56
    .local v1, b:B
    invoke-virtual {p0, v1}, Lorg/jboss/netty/handler/codec/http/websocketx/UTF8Output;->write(I)V

    .line 55
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 58
    .end local v1           #b:B
    :cond_0
    return-void
.end method
